package com.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bean.SmallSort;
import com.bean.PageBean;
import com.serve.SmallSortService;
import com.serveImple.SmallSortServiceImpl;

/**
 * Servlet implementation class ShowServlet
 */
@WebServlet("/SmallSortServlet")
public class SmallSortServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SmallSortServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		int defaultPage=1;
		
		//处理从页面分页请求的当前页
		
		PageBean pb=new PageBean();
		pb.setCurrentPage(defaultPage); //默认获取第一页的数据
		
		String str =request.getParameter("currentPage");
		if(str!=null){
			int number=Integer.parseInt(str);
			pb.setCurrentPage(number);
		}
		pb.setBs_id(1);
		String string =request.getParameter("name");
		if(string.equals("")){			
		}else{
			int num=Integer.parseInt(string);
			pb.setBs_id(num);
		}
		
		SmallSortService SmallSortService=new SmallSortServiceImpl();
		List<SmallSort> SmallSortlist=SmallSortService.show(pb);
		System.out.println(SmallSortlist);
		request.setAttribute("pb",pb);
		request.setAttribute("SmallSortlist",SmallSortlist);
		System.out.println(SmallSortlist);
		//转发
		request.getRequestDispatcher("easybuy/addGoods.jsp").forward(request, response);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request,response);
	}

}
